home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / basic / qbfaqr01.zip / USEKEYB.BAS < prev    next >
BASIC Source File  |  1992-08-10  |  920b  |  29 lines

  1. 'To use cursor keys and function keys, etc ...
  2.  
  3. DO
  4.    'Get a key from the keyboard
  5.    DO
  6.       A$ = INKEY$
  7.    LOOP UNTIL LEN(A$)
  8.    'Check if it's a extended (special) key
  9.    IF LEN(A$) = 2 THEN
  10.       'If it is then, make the key code negative
  11.       KY = -ASC(RIGHT$(A$, 1))
  12.    ELSE
  13.       'If normal (within ASCII 1 - 255 range), then make it positive
  14.       KY = ASC(A$)
  15.    END IF
  16.  
  17.    'Un-comment the following line to test for keycodes
  18.    'PRINT KY          'This will give you a specific number to put into your
  19.                       '  SELECT CASE structure for the key you pressed
  20.    
  21.    'Use SELECT CASE structure to test for keys
  22.    SELECT CASE KY
  23.       CASE 27         'ESC key pressed
  24.          EXIT DO      'bail out
  25.       'Now you can do whatever you want to the key
  26.       'CASE ..., etc ...
  27.    END SELECT
  28. LOOP                   'Infinite loop, bail out when ESC pressed (in SELECT)
  29.